package com.cd2cd.code_template.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RuleVerify {

    public static boolean isMobile(String mobile){
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
        Matcher m = p.matcher(mobile);
        return m.matches();
    }

    public static boolean isEmail(String email){
        String str="^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$";
        Pattern p = Pattern.compile(str);
        Matcher m = p.matcher(email);
        return m.matches();
    }

    public static boolean isIdCard(String idCard){
        String str = "^[1-9]\\d{5}[1-9]\\d{3}((0[1-9])|(1[0-2]))(0[1-9]|([1|2][0-9])|3[0-1])((\\d{4})|\\d{3}X)$";
        Pattern p = Pattern.compile(str);
        Matcher m = p.matcher(idCard);
        return m.matches();
    }

    public static void main(String[] args) {

        System.out.println(isEmail("ffdsf435646@qq.com"));
    }

}
